package com.blog.cmrpersonalblog.enums;

import lombok.Getter;

/**
 * 榜单类型枚举
 */
@Getter
public enum RankingType {
    
    /**
     * 文章榜
     */
    ARTICLE("ARTICLE", "文章榜", "基于文章热度的排行榜"),
    
    /**
     * 作者榜
     */
    AUTHOR("AUTHOR", "作者榜", "基于作者影响力的排行榜"),
    
    /**
     * 收藏榜
     */
    COLLECTION("COLLECTION", "收藏榜", "基于文章收藏数的排行榜");
    
    /**
     * 类型代码
     */
    private final String code;
    
    /**
     * 类型名称
     */
    private final String name;
    
    /**
     * 类型描述
     */
    private final String description;
    
    RankingType(String code, String name, String description) {
        this.code = code;
        this.name = name;
        this.description = description;
    }
    
    /**
     * 根据代码获取枚举
     */
    public static RankingType fromCode(String code) {
        for (RankingType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("未知的榜单类型: " + code);
    }
}

